Hệ thống xếp lịch học tín chỉ cho sinh viên CNTT trên PHP & MySQL
111.127 lượt xem;
- home.php
- project /
1 <?php if(!isset($Translation)){ @header('Location: index.php'); exit; } ?>
2 <?php include_once("{$currDir}/header.php"); ?>
3 <?php @include("{$currDir}/hooks/links-home.php"); ?>
4
5 <?php
6 /*
7 Classes of first and other blocks
8 ---------------------------------
9 For possible classes, refer to the Bootstrap grid columns, panels and buttons documentation:
10 Grid columns: http://getbootstrap.com/css/#grid
11 Panels: http://getbootstrap.com/components/#panels
12 Buttons: http://getbootstrap.com/css/#buttons
13 */
14 $block_classes = array(
15 'first' => array(
16 'grid_column' => 'col-sm-12 col-md-8 col-lg-6',
17 'panel' => 'panel-warning',
18 'link' => 'btn-warning'
19 ),
20 'other' => array(
21 'grid_column' => 'col-sm-6 col-md-4 col-lg-3',
22 'panel' => 'panel-info',
23 'link' => 'btn-info'
24 )
25 );
26 ?>
27
28 <style>
29 .panel-body-description{
30 margin-top: 10px;
31 height: 100px;
32 overflow: auto;
33 }
34 .panel-body .btn img{
35 margin: 0 10px;
36 max-height: 32px;
37 }
38 </style>
39
40
41 <?php
42 /* accessible tables */
43 $arrTables = get_tables_info();
44 if(is_array($arrTables) && count($arrTables)){
45 /* how many table groups do we have? */
46 $groups = get_table_groups();
47 $multiple_groups = (count($groups) > 1 ? true : false);
48
49 /* construct $tg: table list grouped by table group */
50 $tg = array();
51 if(count($groups)){
52 foreach($groups as $grp => $tables){
53 foreach($tables as $tn){
54 $tg[$tn] = $grp;
55 }
56 }
57 }
58
59 $i = 0; $current_group = '';
60 foreach($tg as $tn => $tgroup){
61 $tc = $arrTables[$tn];
62 /* is the current table filter-first? */
63 $tChkFF = array_search($tn, array());
64 /* hide current table in homepage? */
65 $tChkHL = array_search($tn, array());
66 /* allow homepage 'add new' for current table? */
67 $tChkAHAN = array_search($tn, array());
68
69 /* homepageShowCount for current table? */
70 $count_badge = '';
71 if($tc['homepageShowCount']){
72 $sql_from = get_sql_from($tn);
73 $count_records = ($sql_from ? sqlValue("select count(1) from " . $sql_from) : 0);
74 $count_badge = '<span class="badge hspacer-lg text-bold">' . number_format($count_records) . '</span>';
75 }
76
77 $t_perm = getTablePermissions($tn);
78 $can_insert = $t_perm['insert'];
79
80 $searchFirst = (($tChkFF !== false && $tChkFF !== null) ? '?Filter_x=1' : '');
81 ?>
82 <?php if(!$i && !$multiple_groups){ /* no grouping, begin row */ ?>
83
84 <div class="row table_links">
85 <?php } ?>
86 <?php if($multiple_groups && $current_group != $tgroup){ /* grouping, begin group & row */ ?>
87 <?php if($current_group != ''){ /* not first group, so we should first end previous group */ ?>
88
89 </div><!-- /.table_links -->
90 <div class="row custom_links">
91 <?php
92 /* custom home links for current group, as defined in "hooks/links-home.php" */
93 echo get_home_links($homeLinks, $block_classes['other'], $current_group);
94 ?>
95 </div>
96 </div><!-- /.collapse -->
97 <?php } ?>
98 <?php $current_group = $tgroup; ?>
99
100 <a class="btn btn-primary btn-block btn-lg collapser vspacer-lg" data-toggle="collapse" href="#group-<?php echo md5($tgroup); ?>"><?php echo $tgroup; ?> <i class="glyphicon glyphicon-chevron-right"></i></a>
101 <div class="collapse" id="group-<?php echo md5($tgroup); ?>">
102 <div class="row table_links">
103 <?php } ?>
104
105 <?php if($tChkHL === false || $tChkHL === null){ /* if table is not set as hidden in homepage */ ?>
106 <div id="<?php echo $tn; ?>-tile" class="<?php echo (!$i ? $block_classes['first']['grid_column'] : $block_classes['other']['grid_column']); ?>">
107 <div class="panel <?php echo (!$i ? $block_classes['first']['panel'] : $block_classes['other']['panel']); ?>">
108 <div class="panel-body">
109 <?php if($can_insert && $tChkAHAN !== false && $tChkAHAN !== null){ ?>
110
111 <div class="btn-group" style="width: 100%;">
112 <a style="width: 85%;" class="btn btn-lg <?php echo (!$i ? $block_classes['first']['link'] : $block_classes['other']['link']); ?>" title="<?php echo preg_replace("/&(#[0-9]+|[a-z]+);/i", "&$1;", html_attr(strip_tags($tc['Description']))); ?>" href="<?php echo $tn; ?>_view.php<?php echo $searchFirst; ?>"><?php echo ($tc['tableIcon'] ? '<img src="' . $tc['tableIcon'] . '">' : '');?><strong class="table-caption"><?php echo $tc['Caption']; ?></strong><?php echo $count_badge; ?></a>
113 <a id="<?php echo $tn; ?>_add_new" style="width: 15%;" class="btn btn-add-new btn-lg <?php echo (!$i ? $block_classes['first']['link'] : $block_classes['other']['link']); ?>" title="<?php echo html_attr($Translation['Add New']); ?>" href="<?php echo $tn; ?>_view.php?addNew_x=1"><i style="vertical-align: bottom;" class="glyphicon glyphicon-plus"></i></a>
114 </div>
115 <?php }else{ ?>
116
117 <a class="btn btn-block btn-lg <?php echo (!$i ? $block_classes['first']['link'] : $block_classes['other']['link']); ?>" title="<?php echo preg_replace("/&(#[0-9]+|[a-z]+);/i", "&$1;", html_attr(strip_tags($tc['Description']))); ?>" href="<?php echo $tn; ?>_view.php<?php echo $searchFirst; ?>"><?php echo ($tc['tableIcon'] ? '<img src="' . $tc['tableIcon'] . '">' : '');?><strong class="table-caption"><?php echo $tc['Caption']; ?></strong><?php echo $count_badge; ?></a>
118 <?php } ?>
119
120 <div class="panel-body-description"><?php echo $tc['Description']; ?></div>
121 </div>
122 </div>
123 </div>
124 <?php } ?>
125 <?php if($i == (count($arrTables) - 1) && !$multiple_groups){ /* no grouping, end row */ ?>
126
127 </div> <!-- /.table_links -->
128
129 <div class="row custom_links" id="custom_links">
130 <?php
131 /* custom home links, as defined in "hooks/links-home.php" */
132 echo get_home_links($homeLinks, $block_classes['other'], '*');
133 ?>
134 </div>
135
136 <?php } ?>
137 <?php if($i == (count($arrTables) - 1) && $multiple_groups){ /* grouping, end last group & row */ ?>
138
139 </div> <!-- /.table_links -->
140 <div class="row custom_links" id="custom_links">
141 <?php
142 /* custom home links for last table group, as defined in "hooks/links-home.php" */
143 echo get_home_links($homeLinks, $block_classes['other'], $tgroup);
144
145 /* custom home links having no table groups, as defined in "hooks/links-home.php" */
146 echo get_home_links($homeLinks, $block_classes['other']);
147 ?>
148 </div>
149 </div><!-- /.collapse -->
150 <?php } ?>
151 <?php
152 $i++;
153 }
154 }else{
155 ?><script>window.location='index.php?signIn=1';</script><?php
156 }
157 ?>
158
159 <script>
160 $j(function(){
161 var table_descriptions_exist = false;
162 $j('div[id$="-tile"] .panel-body-description').each(function(){
163 if($j.trim($j(this).html()).length) table_descriptions_exist = true;
164 });
165
166 if(!table_descriptions_exist){
167 $j('div[id$="-tile"] .panel-body-description').css({height: 'auto'});
168 }
169
170 $j('.panel-body .btn').height(32);
171
172 $j('.btn-add-new').click(function(){
173 var tn = $j(this).attr('id').replace(/_add_new$/, '');
174 modal_window({
175 url: tn + '_view.php?addNew_x=1&Embedded=1',
176 size: 'full',
177 title: $j(this).prev().children('.table-caption').text() + ": <?php echo html_attr($Translation['Add New']); ?>"
178 });
179 return false;
180 });
181
182 /* adjust arrow directions on opening/closing groups, and initially open first group */
183 $j('.collapser').click(function(){
184 $j(this).children('.glyphicon').toggleClass('glyphicon-chevron-right glyphicon-chevron-down');
185 });
186
187 /* hide empty table groups */
188 $j('.collapser').each(function(){
189 var target = $j(this).attr('href');
190 if(!$j(target + " .row div").length) $j(this).hide();
191 });
192 $j('.collapser:visible').eq(0).click();
193 });
194 </script>
195
196 <?php include_once("$currDir/footer.php"); ?>
2 <?php include_once("{$currDir}/header.php"); ?>
3 <?php @include("{$currDir}/hooks/links-home.php"); ?>
4
5 <?php
6 /*
7 Classes of first and other blocks
8 ---------------------------------
9 For possible classes, refer to the Bootstrap grid columns, panels and buttons documentation:
10 Grid columns: http://getbootstrap.com/css/#grid
11 Panels: http://getbootstrap.com/components/#panels
12 Buttons: http://getbootstrap.com/css/#buttons
13 */
14 $block_classes = array(
15 'first' => array(
16 'grid_column' => 'col-sm-12 col-md-8 col-lg-6',
17 'panel' => 'panel-warning',
18 'link' => 'btn-warning'
19 ),
20 'other' => array(
21 'grid_column' => 'col-sm-6 col-md-4 col-lg-3',
22 'panel' => 'panel-info',
23 'link' => 'btn-info'
24 )
25 );
26 ?>
27
28 <style>
29 .panel-body-description{
30 margin-top: 10px;
31 height: 100px;
32 overflow: auto;
33 }
34 .panel-body .btn img{
35 margin: 0 10px;
36 max-height: 32px;
37 }
38 </style>
39
40
41 <?php
42 /* accessible tables */
43 $arrTables = get_tables_info();
44 if(is_array($arrTables) && count($arrTables)){
45 /* how many table groups do we have? */
46 $groups = get_table_groups();
47 $multiple_groups = (count($groups) > 1 ? true : false);
48
49 /* construct $tg: table list grouped by table group */
50 $tg = array();
51 if(count($groups)){
52 foreach($groups as $grp => $tables){
53 foreach($tables as $tn){
54 $tg[$tn] = $grp;
55 }
56 }
57 }
58
59 $i = 0; $current_group = '';
60 foreach($tg as $tn => $tgroup){
61 $tc = $arrTables[$tn];
62 /* is the current table filter-first? */
63 $tChkFF = array_search($tn, array());
64 /* hide current table in homepage? */
65 $tChkHL = array_search($tn, array());
66 /* allow homepage 'add new' for current table? */
67 $tChkAHAN = array_search($tn, array());
68
69 /* homepageShowCount for current table? */
70 $count_badge = '';
71 if($tc['homepageShowCount']){
72 $sql_from = get_sql_from($tn);
73 $count_records = ($sql_from ? sqlValue("select count(1) from " . $sql_from) : 0);
74 $count_badge = '<span class="badge hspacer-lg text-bold">' . number_format($count_records) . '</span>';
75 }
76
77 $t_perm = getTablePermissions($tn);
78 $can_insert = $t_perm['insert'];
79
80 $searchFirst = (($tChkFF !== false && $tChkFF !== null) ? '?Filter_x=1' : '');
81 ?>
82 <?php if(!$i && !$multiple_groups){ /* no grouping, begin row */ ?>
83
84 <div class="row table_links">
85 <?php } ?>
86 <?php if($multiple_groups && $current_group != $tgroup){ /* grouping, begin group & row */ ?>
87 <?php if($current_group != ''){ /* not first group, so we should first end previous group */ ?>
88
89 </div><!-- /.table_links -->
90 <div class="row custom_links">
91 <?php
92 /* custom home links for current group, as defined in "hooks/links-home.php" */
93 echo get_home_links($homeLinks, $block_classes['other'], $current_group);
94 ?>
95 </div>
96 </div><!-- /.collapse -->
97 <?php } ?>
98 <?php $current_group = $tgroup; ?>
99
100 <a class="btn btn-primary btn-block btn-lg collapser vspacer-lg" data-toggle="collapse" href="#group-<?php echo md5($tgroup); ?>"><?php echo $tgroup; ?> <i class="glyphicon glyphicon-chevron-right"></i></a>
101 <div class="collapse" id="group-<?php echo md5($tgroup); ?>">
102 <div class="row table_links">
103 <?php } ?>
104
105 <?php if($tChkHL === false || $tChkHL === null){ /* if table is not set as hidden in homepage */ ?>
106 <div id="<?php echo $tn; ?>-tile" class="<?php echo (!$i ? $block_classes['first']['grid_column'] : $block_classes['other']['grid_column']); ?>">
107 <div class="panel <?php echo (!$i ? $block_classes['first']['panel'] : $block_classes['other']['panel']); ?>">
108 <div class="panel-body">
109 <?php if($can_insert && $tChkAHAN !== false && $tChkAHAN !== null){ ?>
110
111 <div class="btn-group" style="width: 100%;">
112 <a style="width: 85%;" class="btn btn-lg <?php echo (!$i ? $block_classes['first']['link'] : $block_classes['other']['link']); ?>" title="<?php echo preg_replace("/&(#[0-9]+|[a-z]+);/i", "&$1;", html_attr(strip_tags($tc['Description']))); ?>" href="<?php echo $tn; ?>_view.php<?php echo $searchFirst; ?>"><?php echo ($tc['tableIcon'] ? '<img src="' . $tc['tableIcon'] . '">' : '');?><strong class="table-caption"><?php echo $tc['Caption']; ?></strong><?php echo $count_badge; ?></a>
113 <a id="<?php echo $tn; ?>_add_new" style="width: 15%;" class="btn btn-add-new btn-lg <?php echo (!$i ? $block_classes['first']['link'] : $block_classes['other']['link']); ?>" title="<?php echo html_attr($Translation['Add New']); ?>" href="<?php echo $tn; ?>_view.php?addNew_x=1"><i style="vertical-align: bottom;" class="glyphicon glyphicon-plus"></i></a>
114 </div>
115 <?php }else{ ?>
116
117 <a class="btn btn-block btn-lg <?php echo (!$i ? $block_classes['first']['link'] : $block_classes['other']['link']); ?>" title="<?php echo preg_replace("/&(#[0-9]+|[a-z]+);/i", "&$1;", html_attr(strip_tags($tc['Description']))); ?>" href="<?php echo $tn; ?>_view.php<?php echo $searchFirst; ?>"><?php echo ($tc['tableIcon'] ? '<img src="' . $tc['tableIcon'] . '">' : '');?><strong class="table-caption"><?php echo $tc['Caption']; ?></strong><?php echo $count_badge; ?></a>
118 <?php } ?>
119
120 <div class="panel-body-description"><?php echo $tc['Description']; ?></div>
121 </div>
122 </div>
123 </div>
124 <?php } ?>
125 <?php if($i == (count($arrTables) - 1) && !$multiple_groups){ /* no grouping, end row */ ?>
126
127 </div> <!-- /.table_links -->
128
129 <div class="row custom_links" id="custom_links">
130 <?php
131 /* custom home links, as defined in "hooks/links-home.php" */
132 echo get_home_links($homeLinks, $block_classes['other'], '*');
133 ?>
134 </div>
135
136 <?php } ?>
137 <?php if($i == (count($arrTables) - 1) && $multiple_groups){ /* grouping, end last group & row */ ?>
138
139 </div> <!-- /.table_links -->
140 <div class="row custom_links" id="custom_links">
141 <?php
142 /* custom home links for last table group, as defined in "hooks/links-home.php" */
143 echo get_home_links($homeLinks, $block_classes['other'], $tgroup);
144
145 /* custom home links having no table groups, as defined in "hooks/links-home.php" */
146 echo get_home_links($homeLinks, $block_classes['other']);
147 ?>
148 </div>
149 </div><!-- /.collapse -->
150 <?php } ?>
151 <?php
152 $i++;
153 }
154 }else{
155 ?><script>window.location='index.php?signIn=1';</script><?php
156 }
157 ?>
158
159 <script>
160 $j(function(){
161 var table_descriptions_exist = false;
162 $j('div[id$="-tile"] .panel-body-description').each(function(){
163 if($j.trim($j(this).html()).length) table_descriptions_exist = true;
164 });
165
166 if(!table_descriptions_exist){
167 $j('div[id$="-tile"] .panel-body-description').css({height: 'auto'});
168 }
169
170 $j('.panel-body .btn').height(32);
171
172 $j('.btn-add-new').click(function(){
173 var tn = $j(this).attr('id').replace(/_add_new$/, '');
174 modal_window({
175 url: tn + '_view.php?addNew_x=1&Embedded=1',
176 size: 'full',
177 title: $j(this).prev().children('.table-caption').text() + ": <?php echo html_attr($Translation['Add New']); ?>"
178 });
179 return false;
180 });
181
182 /* adjust arrow directions on opening/closing groups, and initially open first group */
183 $j('.collapser').click(function(){
184 $j(this).children('.glyphicon').toggleClass('glyphicon-chevron-right glyphicon-chevron-down');
185 });
186
187 /* hide empty table groups */
188 $j('.collapser').each(function(){
189 var target = $j(this).attr('href');
190 if(!$j(target + " .row div").length) $j(this).hide();
191 });
192 $j('.collapser:visible').eq(0).click();
193 });
194 </script>
195
196 <?php include_once("$currDir/footer.php"); ?>